import javax.servlet.*;
import java.io.IOException;
import java.util.Enumeration;

public class Filter2 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("Filter2 init-------------------------");
        System.out.println("参数:");
        Enumeration<String> initParameterNames = filterConfig.getInitParameterNames();
        while (initParameterNames.hasMoreElements()) {
            String key = initParameterNames.nextElement();
            System.out.println(key + ":" + filterConfig.getInitParameter(key));
        }
        System.out.println("-------------------------------------");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("Filter2.doFilter before filterChain.doFilter");
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("Filter2.doFilter after filterChain.doFilter");
    }

    @Override
    public void destroy() {
        System.out.println("Filter2.destroy");
    }
}
